package org.p2psimulator.entity.reputation;

import org.p2psimulator.entity.Id;

public abstract class Reputation {

	protected double numplus;

	protected double numminus;

	protected double normalizedValue = 0;

	private Id rater;

	private Id ratee;


        public void resetReputation(){
            numplus = 0;
            numminus = 0;
            normalizedValue = 0;
        }
	public Id getRater() {
		return rater;
	}

	public void setRater(Id rater) {
		this.rater = rater;
	}

	public Id getRatee() {
		return ratee;
	}

	public void setRatee(Id ratee) {
		this.ratee = ratee;
	}

	public void setNumplus(double numplus) {
		this.numplus = numplus;
	}

	public void setNumminus(double numminus) {
		this.numminus = numminus;
	}

	public void incMinus(){
		numminus++;
	}

	public void incPlus(){
		numplus++;
	}
	public double getNumplus() {
		return numplus;
	}

	public double getNumminus() {
		return numminus;
	}

	public double getAverageReputation(){

		if ((numplus+numminus) != 0)
			return (numplus-numminus)/(numplus+numminus);
		else
			return 0;
	}

	public double getNormalReputation(){
		return numplus - numminus;
	}
	public double getTotalInteractions() {
		return numplus + numminus;
	}


	public double getNormalizedValue() {
		return normalizedValue;
	}

	public void setNormalizedValue(double normalizedValue) {
		this.normalizedValue = normalizedValue;
	}

	public Reputation(double numplus, double numminus, Id rater, Id ratee) {
		super();
		this.numplus = numplus;
		this.numminus = numminus;
		this.rater = rater;
		this.ratee = ratee;
	}

}
